package com.example.image

import android.content.Context
import android.widget.ImageView
import com.example.image.impl.GlideImpl
import com.example.image.impl.PicassoImpl
import java.io.File

class ImageLoader : IImageLoader {
    var loader : IImageLoader? = null
    constructor(imageLoaderType : ImageLoaderType){
        when(imageLoaderType){
            ImageLoaderType.Glide->loader = GlideImpl()
            ImageLoaderType.Picasso->loader = PicassoImpl()
            else->loader = GlideImpl()
        }
    }
    override fun loadFromUrl(
        context: Context,
        path: String,
        imageView: ImageView,
        imageOptions: ImageOptions
    ) {
        loader?.loadFromUrl(context,path,imageView,imageOptions)
    }

    override fun loadFromFile(
        context: Context,
        path: File,
        imageView: ImageView,
        imageOptions: ImageOptions
    ) {
        loader?.loadFromFile(context,path,imageView,imageOptions)
    }

    override fun loadFromResoure(
        context: Context,
        path: Int,
        imageView: ImageView,
        imageOptions: ImageOptions
    ) {
        loader?.loadFromResoure(context,path,imageView,imageOptions)
    }
}